<!-- 打回修改 -->
<template>
	<!-- 选择模态框 -->
	<u-popup :show="show" :round="8">
		<view class="modify-modal">
			<view class="modify-modal-title">
				<view class="modal-title">{{title}}</view>
				<view class="modal-cancel" @click="cancel">取消 </view>
			</view>
			<view class="modal-content">
				<view style="padding: 0 30rpx">
					<textarea class="textarea" v-model="content"
						placeholder="请输入评语(必填)">
          </textarea>

					<view class="quick-word" @click="quickShow = true"> 快捷评语
					</view>
				</view>
				<view class="submit-box">
					<view class="submit-btn" @click="submit">确定</view>
				</view>
			</view>
			<QuickWord :visible="quickShow" @change="quickWordChange">
			</QuickWord>
		</view>
	</u-popup>
</template>

<script>
	import {
		remarkSave,
	} from "@/pages/achievement/api/teacher.js";

	import QuickWord from "./quickWord.vue";
	import deepClone from "@/util/deepClone.js";


	export default {
		components: {
			QuickWord,
		},
		props: {
			visible: {
				type: Boolean,
				default: false,
			},
			//  
			title: {
				type: '',
				default: () => '',
			},
			classCourseId: {
				type: '',
				default: () => '',
			},
			remark: {
				type: '',
				default: () => '',
			},
		},
		watch: {
			visible(newVal) {
				console.log(newVal)
				this.show = newVal;
				this.content = this.remark
			},
		},
		data() {
			return {
				quickShow: false,
				show: false,
				content: "",
			};
		},
		methods: {

			cancel() {
				this.content = "";
				const data = {
					remark: this.content
				};
				this.$emit("change", { hide: false, data });
			},
			quickWordChange(data) {
				if (data.msg) {
					this.content = data.msg;
				}
				this.quickShow = data.hide;
			},

			submit() {
				const data = {
					remark: this.content,
					classCourseId: this.classCourseId
				};
				if (this.title == '科目备注') {

					remarkSave(data).then((res) => {
						if (res.success) {
							uni.showToast({
								icon: "success",
								title: "保存成功",
							});
							this.$emit("change", {
								hide: false,
								reload: true,
								data
							});
						} else {
							uni.showToast({
								icon: "none",
								title: res.msg,
							});
						}
					});
				} else {
					this.$emit("change", {
						hide: false,
						reload: true,
						data
					});
				}
			},
		},
	};
</script>

<style lang="scss" scoped>
	.modify-modal {
		.modify-modal-title {
			position: relative;
			// width: 100%;
			height: 108rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			padding: 0 30rpx;
			font-size: 30rpx;
			color: #333;
			margin-bottom: 24rpx;

			.modal-title {
				font-size: 34rpx;
				font-weight: 500;
			}

			.modal-cancel {
				position: absolute;
				right: 30rpx;
			}
		}

		.modal-content {
			.textarea {
				width: 100%;
				height: 410rpx;
				padding: 32rpx 0;
				box-sizing: border-box;
				font-size: 30rpx;
				margin-bottom: 10rpx;
			}

			.quick-word {
				width: 152rpx;
				height: 48rpx;
				border: 1rpx solid #4174fd;
				border-radius: 25rpx;
				color: #4174fd;
				font-size: 26rpx;
				text-align: center;
				line-height: 48rpx;
				margin-bottom: 20rpx;
			}
		}

		.submit-box {
			height: 98rpx;
			padding: 14rpx 30rpx 54rpx;
			margin-top: 32rpx;
			background: #fff;
			box-shadow: 0px -0.5px 0px 0px #e5e5e5;

			.submit-btn {
				width: 690rpx;
				height: 72rpx;
				background: #4174fd;
				border-radius: 36rpx;
				text-align: center;
				line-height: 72rpx;
				color: #fff;
				font-size: 30rpx;
			}
		}
	}
</style>
